import Page
from Page import Map
from Base.Base import Base
from selenium.webdriver.common.by import By


class MapSimulationPage(Base):
    """
    模拟导航界面

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.simulation_home_btn = (By.XPATH, Map.RESOURCE_ID.format("rl_navigation_home"))

        # 左侧的返回键
        self.simulation_back_btn = (By.XPATH, Map.RESOURCE_ID.format('rl_navigation_back'))

        # 路线详情
        self.simulation_route_details_btn = (By.XPATH, Map.RESOURCE_ID.format('tv_route_detail'))

        # 路线调整
        self.simulation_route_adjustment_btn = (By.XPATH, Map.RESOURCE_ID.format('tv_route_adjust'))

        # 路线优势
        self.simulation_route_advantage_text = (By.XPATH, Map.RESOURCE_ID.format('tv_route_name'))

        # 路线时间
        self.simulation_journey_time_text = (By.XPATH, Map.RESOURCE_ID.format('tv_route_time'))

        # 路线距离
        self.simulation_journey_distance_text = (By.XPATH, Map.RESOURCE_ID.format('tv_route_dis'))

        # 红绿灯数量
        self.simulation_traffic_lights_text = (By.XPATH, Map.RESOURCE_ID.format('tv_route_light'))

        # 从我位置出发文案
        self.simulation_set_off_text = (By.XPATH, Page.TEXT.format("从 我的位置 出发"))

        # 模拟导航按钮
        self.simulation_navigation_btn = (By.XPATH, Map.RESOURCE_ID.format("tv_routeplaninfo_simulate"))

        # 路线图标
        self.simulation_route_icon = (By.XPATH, Map.route_icon.format(""))

        # 当前路线距离
        self.simulation_current_route_distance_text = (By.XPATH, Map.current_route_distance_text.format(""))

        # 路径描述
        self.simulation_path_description_text = (By.XPATH, Map.path_description_text.format(""))

        # 开始导航
        self.simulation_start_navigation_btn = (By.XPATH, Map.RESOURCE_ID.format("ll_routeplaninfo_start"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None

        """
        self.click_element(self.simulation_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.simulation_back_btn)

    def click_route_details(self):
        """
        点击路线详情

        :return:None
        """
        self.click_element(self.simulation_route_details_btn)

    def click_route_adjustment(self):
        """
        点击路线调整

        :return:None
        """
        self.click_element(self.simulation_route_adjustment_btn)

    def get_route_advantage(self):
        """
        获取路线优势文案

        :return:获取元素
        """
        return self.find_element_o(self.simulation_route_advantage_text)

    def get_journey_time(self):
        """
        获取路线时间文案

        :return:获取元素
        """
        return self.find_element_o(self.simulation_journey_time_text)

    def get_journey_distance(self):
        """
        获取路线距离文案

        :return:获取元素
        """
        return self.find_element_o(self.simulation_journey_distance_text)

    def get_traffic_lights(self):
        """
        获取路线距离文案

        :return:获取元素
        """
        return self.find_element_o(self.simulation_traffic_lights_text)

    def get_set_off(self):
        """
        获取从我位置出发文案

        :return:获取元素
        """
        return self.find_element_o(self.simulation_set_off_text)

    def click_navigation(self):
        """
        点击模拟导航按钮

        :return:None
        """
        self.click_element(self.simulation_navigation_btn)

    def get_route(self, index=1):
        """
        获取路线图标图标

        :return:获取元素
        """
        self.simulation_route_icon = (By.XPATH, Map.route_icon.format(index))
        return self.find_element_o(self.simulation_route_icon)

    def get_current_route_distance(self, index=1):
        """
        获取当前路线距离文案

        :return:获取元素
        """
        self.simulation_current_route_distance_text = (By.XPATH, Map.current_route_distance_text.format(index))
        return self.find_element_o(self.simulation_current_route_distance_text)

    def get_path_description(self, index=1):
        """
        获取当前路线距离文案

        :return:获取元素
        """
        self.simulation_path_description_text = (By.XPATH, Map.path_description_text.format(index))
        return self.find_element_o(self.simulation_path_description_text)

    def click_start_navigation(self):
        """
        点击开始导航按钮

        :return:None
        """
        self.click_element(self.simulation_start_navigation_btn)

    def is_display_map_simulation(self):
        """
        查看是否进入模拟导航首页

        :return:
        """
        return self.is_display(self.simulation_route_details_btn)
